//
//  LBHTTPConfiguration.h
//  LBNetworking
//
//  Created by WuShiHai on 19/5/30.
//  Copyright (c) 2019 Lebbay. All rights reserved.
//

#import <Foundation/Foundation.h>

@class LBHTTPResponseConfiguration;

@interface LBHTTPConfiguration : NSObject

/**
 {
    "timeoutInterval":60
    "response":[LBHTTPResponseConfiguration defaultConfiguration]
 }

 @return new configuration
 */
+ (instancetype)defaultConfiguration;

/**
 超时时间，默认60s
 */
@property (nonatomic, assign) NSTimeInterval timeoutInterval;

/**
 服务器用来解析的映射key
 */
@property (nonatomic, strong) LBHTTPResponseConfiguration *response;

@end


/**
 服务器返回的数据解析配置
 */
@interface LBHTTPResponseConfiguration : NSObject

/**
 {
    "codeKey":"code"
    "dataKey":"data"
    "messageKey":"message"
    "successCode":0
 }
 
 @return new configuration
 */
+ (instancetype)defaultConfiguration;

@property (nonatomic, strong) NSString *codeKey;
@property (nonatomic, strong) NSString *dataKey;
@property (nonatomic, strong) NSString *messageKey;

/**
 默认 0 为成功码
 */
@property (nonatomic, assign) NSInteger successCode;

/**
 默认为nil，如果设置，则服务端返回与该字符串相同的code值才会认为成功。
 */
@property (nonatomic, strong) NSString *successCodeStr;

/**
 判断code是否为成功码

 @param code code
 @return 是否成功
 */
- (BOOL)isSuccess:(id)code;

@end
